package webbeans;

import java.util.ArrayList;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;

import dao.LoginDAO;
import exceptions.DAOException;

@SessionScoped
@ManagedBean(name="loginManager")
public class LoginManager {

	private String login;
	private String pass;
	LoginDAO dao ;
	
	public LoginManager(){
		dao = new LoginDAO();
	}
	
	
	public void login(ActionEvent event){
		try {
			ArrayList<String> list= dao.getLoginPass(this.login);
			if(list.get(1).equals(this.pass)){
				System.out.println("logowanie ok");
			}else{
				System.out.println("logowanie fail");
			}
			
		} catch (DAOException e) {
			e.addErrorMessage(event.getComponent());
		}
		
	}
	

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getPass() {
		return pass;
	}

	public void setPass(String pass) {
		this.pass = pass;
	}
	
	
}
